<template>
  <el-select
    v-model="value"
    clearable
    reserve-keyword
    filterable
    :remote-method="remoteSupplier"
    @change="change"
  >
    <el-option
      v-for="item in supplierList"
      :key="item.id"
      :label="item.supplierName"
      :value="item.id"
    >
    </el-option>
  </el-select>
</template>

<script>
import {getList} from "@/ModuleSysBusiness/api/Supplier/Supplier.js";
export default {
  name: "SupplierList",
  components: {},
  props: {
    value: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      supplierList: [],
    };
  },
  created() {
    this.initData();
  },
  methods: {
    change() {
      this.$emit("input", this.value);
    },
    initData() {
      getList({ status: 1 }, { pageIndex: 1, pageSize: 10000 })
        .then((res) => {
          this.supplierList = res.data.dataList;
        });
    },
    remoteSupplier(query) {
    getList({
          status: 1,
          supplierName: query,
          pageIndex: 1,
          pageSize: 10000,
        })
        .then((res) => {
          this.supplierList = res.data.dataList;
        });
    },
  },
};
</script>
<style scoped>
</style>
